home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 2
/
Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso
/
Aminet
/
dev
/
misc
/
egs.lha
/
EGS
/
EGS_Devels
/
Examples
/
EGS_Requester
/
requester.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-17
|
6KB
|
238 lines
/*
** Author: Markus van Kempen
** Date : 18. Dezember 1992
** 09 Jan 1993 mvk
**
** This example shows how to work with EGS_REQUESTER.
**
** It is an example for non modal requester.
**
** You can request a lot of messages without waiting for
**
** response from the user to the requester.
**
** For example in the file requester: if the user makes some
**
** mistakes (like to select a file as a device) then you can put up
**
** a requester for him.
**
**
**
** (c) by VIONA-Development 1992/93
**
*/
/*
** Init-Routines
*/
#include "global.h"
/*
**
*/
ER_FileRequestPtr freq;
ER_SimpleRequestPtr sreq,sreq1,sreq2,sreq3;
EI_EIntuiMsgPtr msg;
ER_ReqContextPtr mycon;
ER_RequestPtr req;
struct MsgPort *port;
BOOL done;
int i;
void myError(char *string,int ende)
{
if ( string != NULL)
printf("%s\n",string);
if ( ErrorReq != NULL )
ER_DeleteRequest(&(ErrorReq->Req));
CloseLibraries(OpenStruct);
if (ende)
exit(0);
}
/*
**
** Open the Libraries
**
*/
BOOL InitLibraries(struct OpenStructTyp *OS)
{
struct OpenStructTyp *p = &OS[0];
while (p->Base != NULL)
{
if ((*(p->Base) = (ULONG)OpenLibrary(p->Name,p->Version)) == NULL)
{
printf(" Can't open %s version %d",p->Name, p->Version);
return FALSE;
}
else
{ p ++; }
}
return TRUE;
}
/**/
/*
**
** Close Libs
**
*/
void CloseLibraries(struct OpenStructTyp *OS)
{
struct OpenStructTyp *p = &OS[0];
while (*(p->Base) != NULL && p->Name != NULL)
{
CloseLibrary((void *)(*(p->Base)));
*(p->Base) = NULL;
p++;
}
}
main()
{
if ( InitLibraries(OpenStruct) == FALSE)
myError("Can't OpenLibrary",10);
port = CreatePort(NULL,0);
if ( port == NULL )
myError("Can't create port",10);
mycon = ER_CreateReqContext();
if (mycon != NULL)
{
/*
** Create the context for all
*/
freq=ER_CreateFileReq(mycon);
sreq=ER_CreateSimpleRequest(mycon,
" ! ERROR ! | You selected a filename | as a device !",
" YES | MAY BE | NO ");
sreq1=ER_CreateSimpleRequest(mycon,
" ! ERROR ! | The selected path | doesn't exist !",
" YES | MAY BE | NO ");
sreq2=ER_CreateSimpleRequest(mycon,
" ! ERROR ! | You selected a wrong | devicename !",
" YES | MAY BE | NO ");
sreq3=ER_CreateSimpleRequest(mycon,
" This is a demo | for non modal | requesters !",
" YES ");
/*
** Init Port in requester struct for use of
** non modal requesters.
**
** Without a port the OpenRequest will create
** a own port, so that any requester has an own
** MsgPort (modal).
**
**
*/
freq->Req.Port=port;
sreq->Req.Port=port;
sreq1->Req.Port=port;
sreq2->Req.Port=port;
sreq3->Req.Port=port;
if (sreq1 != NULL && sreq2 != NULL && sreq3 != NULL)
if (freq != NULL && sreq != NULL)
{
freq->Req.Title="Titel1";
sreq->Req.Title="Titel2";
sreq1->Req.Title="Titel3";
sreq2->Req.Title="Titel4";
sreq3->Req.Title="Titel5";
done=FALSE;
if ( ER_OpenRequest((ER_RequestPtr)freq,NULL) &&
ER_OpenRequest((ER_RequestPtr)sreq,NULL) &&
ER_OpenRequest((ER_RequestPtr)sreq2,NULL) &&
ER_OpenRequest((ER_RequestPtr)sreq1,NULL) &&
ER_OpenRequest((ER_RequestPtr)sreq3,NULL)
)
{
do{
WaitPort(port);
msg=(EI_EIntuiMsgPtr)GetMsg((struct MsgPort *)port);
if (msg != NULL)
{
/*
** Find the Requester for the msg
**
** if req == NULL the msg
** is not from a EGS Requester
**
*/
req = ER_FindRequest(mycon,msg);
if (req != NULL)
{
/*
** Handle the msg !
** For example close requester
*/
ER_IterateRequest(req,msg);
// printf("Selected gadget%d\n",sreq->Selected);
}
}
ReplyMsg((struct Message *)msg);
}while(freq->Req.RWindow != NULL);
printf("Name = %s \n\n",freq->Name);
}
}
}
if( con != NULL )
ER_DeleteReqContext(mycon);
DeletePort(port);
myError(NULL,10);
}
/* END */